<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <script src="https://cdnjs.cloudflare.com/ajax/libs/axios/1.3.4/axios.min.js"></script>
    <script src="https://img.ins-box.com/static/js/vue_3.js"></script>
    <style>
      body {
        margin: 0;
      }
      .alipay {
        background: linear-gradient(315deg, #473a3a, #dedede);
        height: 100vh;
        width: 100vw;
        font-family: KaiTi, STKaiti, '楷体', serif;
      }
      .alipay-content {
        width: 120px;
        margin: auto;
        filter: blur(0.6px);
        text-align: center;
      }
      .alipay-content img {
        width: 70px;
        height: 80px;
        margin: 40px 0 20px 0;
      }
      .alipay-content .alipay-text {
        color: white;
        font-size: 18px;
        font-weight: 600;
      }
      .alipay-popup {
        width: 100%;
        position: fixed;
        left: 0;
        top: 0;
        opacity: 0.6;
        z-index: 1000;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.8);
        pointer-events: auto;
        color: white;
        display: flex;
        flex-direction: column;
        align-items: center;
        font-size: 15px;
        font-weight: 700;
      }
      .flex {
        display: flex;
      }
      .center {
        align-items: center;
      }
      .alipay-popup__img1 {
        object-fit: cover;
        width: 30px;
        height: 30px;
      }
      .alipay-popup__more {
        width: 40px;
        height: 40px;
      }
      .alipay-popup__webkit {
        width: 40px;
        height: 40px;
        object-fit: cover;
        background-image: url('../img/cdc/webkit.png');
        background-size: cover;
        background-clip: content-box;
        margin-right: 7px !important;
      }
      .popup {
        width: 300px;
        margin-top: 50%;
        margin-bottom: 25px;
      }
      .mx-5 {
        margin: 0px 5px;
      }
      #canvasId {
        border: none;
        position: absolute;
        left: 73%;
        top: 9%;
        transform: rotate(18deg);
      }
      .alipay-popup__img {
        pointer-events: none;
        width: 600px;
        height: 600px;
        position: absolute;
        left: -44%;
        top: 1%;
        transform: rotate(-11deg);
      }
      .confirm {
        margin-top: 30px;
        font-size: 18px;
        font-weight: 700;
        display: flex;
        font-family: SimSun, Arial, sans-serif;
        justify-content: center;
        align-items: center;
      }
      #confirm {
        width: 120px;
        color: #fff;
        text-align: center;
        background-color: #0b7bd4;
        border-radius: 15px;
        position: relative;
        margin: 0 auto;
        margin-left: 10px;
        padding: 8px 12px;
        line-height: 18px;
      }
    </style>
  </head>
  <body>
    <div id="app">
      <div class="alipay">
        <div class="alipay-content">
          <img src="../img/cdc/ali.png" />
          <div class="alipay-text">支付宝支付</div>
        </div>
        <div v-if="isWechat" class="alipay-popup">
          <img src="../img/cdc//arrow1.png" class="alipay-popup__img" @click="test" />
          <div class="flex center popup" style="margin: 200px 0 0 0;">
            <img src="../img/cdc/1.png" class="alipay-popup__img1" />
            <div class="mx-5">点击右上角</div>
            <img src="../img/cdc/more1.png" class="alipay-popup__more mx-5" />
            <div>打开菜单</div>
          </div>
          <div class="flex center popup" style="margin: 20px 0 0 0;">
            <img src="../img/cdc/2.png" class="alipay-popup__img1" />
            <div class="mx-5">选择在</div>
            <div class="alipay-popup__webkit mx-5"></div>
            <div>浏览器中打开</div>
          </div>
          <div class="confirm">
            若已付款，请查看
            <div id="confirm" @click="jumpDetail">订单详情</div>
          </div>
        </div>
      </div>
    </div>
  </body>
</html>
<script>
  Object.assign(window, Vue)
  const { ref, createApp, onMounted } = Vue
  const app = createApp({
    setup() {
      const ua = window.navigator.userAgent.toLowerCase().indexOf('micromessenger') !== -1 ? true : false
      const isWechat = ref(ua)
      const src = ref()
      const canvasRef = ref()
      const url = ref()
      src.value = `${window.location.origin}/static/img/cdc/ali.png`
      function getUrlKey(name) {
        return (
          decodeURIComponent(
            (new RegExp(`[?|&]${name}=([^&;]+?)(&|#|;|$)`).exec(decodeURIComponent(location.href)) || [undefined, ''])[1].replace(/\+/g, '%20')
          ) || null
        )
      }

      function jumpDetail() {
        window.location.href = url.value
      }

      onMounted(async () => {
        const token = localStorage.getItem('group_token')
        const topActualId = getUrlKey('topActualId')
        const regex = /returnUrl=([^&]+)/
        const match = window.location.href.match(regex)
        const returnUrl = match ? decodeURIComponent(match[1]) : null
        url.value = returnUrl
        if (!isWechat.value) {
          let {
            data: { data, message, statusCode }
          } = await axios.get(
            `${window.location.origin}/api/policy/${topActualId}/applyPay/alipay_web?topActualId=${topActualId}&returnUrl=${returnUrl}`
          )
          let { action } = JSON.parse(data)
          if (statusCode === 200 && typeof action === 'string' && action !== '') {
            window.location.href = action
          } else if (statusCode !== 200) {
            console.error(message)
          }
        }
      })
      return {
        src,
        isWechat,
        url,
        jumpDetail
      }
    }
  })
  app.mount('#app')
</script>
